/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <edds/dds/builtin/lookup/common/LookupTypes.hpp>

using namespace evbs;
using namespace vbsutil::ecdr;
using namespace vbsutil::ecdr::exception;
using namespace evbs::edds::dds::builtin;

using evbs::ertps::types::TypeIdentifier;
using evbs::ertps::types::TypeIdentifierPair;
using evbs::ertps::types::TypeIdentifierTypeObjectPair;
using evbs::ertps::types::TypeIdentifierWithSize;

static void serializeGuid(vbsutil::ecdr::Cdr& cdr, const ertps::rtps::GUID_t& guid) {
    for (uint32_t i = 0; i < sizeof(guid.guidPrefix); i++) {
        cdr << guid.guidPrefix.value[i];
    }

    for (uint32_t i = 0; i < sizeof(guid.entityId); i++) {
        cdr << guid.entityId.value[i];
    }
}

static void deserializeGuid(vbsutil::ecdr::Cdr& cdr, ertps::rtps::GUID_t& guid) {
    for (uint32_t i = 0; i < sizeof(guid.guidPrefix); i++) {
        cdr >> guid.guidPrefix.value[i];
    }

    for (uint32_t i = 0; i < sizeof(guid.entityId); i++) {
        cdr >> guid.entityId.value[i];
    }
}

size_t Statistic_getInfoByGuid_Req::getCdrSerializedSize(const Statistic_getInfoByGuid_Req& data,
                                                         size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + sizeof(data.guid_);
    return current_alignment - initial_alignment;
}

void Statistic_getInfoByGuid_Req::serialize(vbsutil::ecdr::Cdr& cdr) const {
    serializeGuid(cdr, guid_);
}

void Statistic_getInfoByGuid_Req::deserialize(vbsutil::ecdr::Cdr& cdr) {
    deserializeGuid(cdr, guid_);
}

size_t Lookup_getTypeInfo_Req::getCdrSerializedSize(const Lookup_getTypeInfo_Req& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + data.type_name.size() + 1;
    return current_alignment - initial_alignment;
}

void Lookup_getTypeInfo_Req::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << type_name;
}

void Lookup_getTypeInfo_Req::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> type_name;
}

size_t Lookup_getTypes_Req::getCdrSerializedSize(const Lookup_getTypes_Req& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    for (size_t a = 0; a < data.type_ids.size(); ++a) {
        current_alignment += TypeIdentifier::getCdrSerializedSize(data.type_ids.at(a), current_alignment);
    }

    return current_alignment - initial_alignment;
}

void Lookup_getTypes_Req::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << type_ids;
}

void Lookup_getTypes_Req::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> type_ids;
}

size_t Lookup_remoteConfig_Req::getCdrSerializedSize(const Lookup_remoteConfig_Req& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + data.param_name.size() + 1;
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + data.host_name.size() + 1;

    return current_alignment - initial_alignment;
}

void Lookup_remoteConfig_Req::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << pid;
    scdr << param_name;
    scdr << host_name;
}

void Lookup_remoteConfig_Req::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> pid;
    dcdr >> param_name;
    dcdr >> host_name;
}

size_t ProxyInfo::getCdrSerializedSize(const ProxyInfo& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 1 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // type
    current_alignment += 1 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // alive
    current_alignment += 8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 8U);  // start time

    if (data.type == STATICTIC_ENTITY_WRITER) {
        // writer proxy.
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // last heartbeart count
        current_alignment +=
            24 + vbsutil::ecdr::Cdr::alignment(current_alignment,
                                               8U);  // last notified, available_changes_max, max_sequence_number
        current_alignment +=
            1 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // writer_proxy_locators_entry.enabled
        current_alignment +=
            16 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // writer_proxy_locators_entry.remote_guid
        current_alignment +=
            8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) +
            (data.writer_proxy_locators_entry.unicast.size() + data.writer_proxy_locators_entry.multicast.size()) * 28;
    } else {
        // reader proxy
        current_alignment +=
            8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 8U);  // last acknack count, last nackfrag_count
        current_alignment += 8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 8U);  // changes_low_mark
        current_alignment +=
            1 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // reader_proxy_general_locator_entry.enabled
        current_alignment += 16 + vbsutil::ecdr::Cdr::alignment(current_alignment,
                                                                4U);  // reader_proxy_general_locator_entry.remote_guid
        current_alignment += 8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) +
                             (data.reader_proxy_general_locator_entry.unicast.size() +
                              data.reader_proxy_general_locator_entry.multicast.size()) *
                                 28;
        current_alignment +=
            1 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // reader_proxy_async_locator_entry.enabled
        current_alignment +=
            16 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // reader_proxy_async_locator_entry.remote_guid
        current_alignment += 8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) +
                             (data.reader_proxy_async_locator_entry.unicast.size() +
                              data.reader_proxy_async_locator_entry.multicast.size()) *
                                 28;
    }
    return current_alignment - initial_alignment;
}

static void serializeLocatorEntry(vbsutil::ecdr::Cdr& cdr, const ertps::rtps::LocatorSelectorEntry& entry) {
    cdr << entry.enabled;
    serializeGuid(cdr, entry.remote_guid);

    uint32_t size = entry.unicast.size();
    cdr << size;
    for (auto& lo : entry.unicast) {
        std::vector<octet> vector_(lo.address, lo.address + sizeof(lo.address));
        cdr << vector_;
        cdr << lo.port;
        cdr << lo.mask_len;
    }

    size = entry.multicast.size();
    cdr << size;
    for (auto& lo : entry.multicast) {
        std::vector<octet> vector_(lo.address, lo.address + sizeof(lo.address));
        cdr << vector_;
        cdr << lo.port;
        cdr << lo.mask_len;
    }
}

static void deserializeLocatorEntry(vbsutil::ecdr::Cdr& cdr, ertps::rtps::LocatorSelectorEntry& entry) {
    cdr >> entry.enabled;
    deserializeGuid(cdr, entry.remote_guid);

    uint32_t size = 0;
    cdr >> size;
    for (uint32_t i = 0; i < size; i++) {
        Locator_t locator;
        std::vector<octet> vector_;
        cdr >> vector_;
        std::copy(vector_.begin(), vector_.end(), locator.address);
        cdr >> locator.port;
        cdr >> locator.mask_len;
        entry.unicast.push_back(locator);
    }
    cdr >> size;
    for (uint32_t i = 0; i < size; i++) {
        Locator_t locator;
        std::vector<octet> vector_;
        cdr >> vector_;
        std::copy(vector_.begin(), vector_.end(), locator.address);
        cdr >> locator.port;
        cdr >> locator.mask_len;
        entry.multicast.push_back(locator);
    }
}

void ProxyInfo::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << type;
    cdr << is_alive;
    cdr << start_time;
    if (type == STATICTIC_ENTITY_WRITER) {
        cdr << last_heartbeat_count;
        cdr << last_notified;
        cdr << available_changes_max;
        cdr << max_sequence_number;
        serializeLocatorEntry(cdr, writer_proxy_locators_entry);
    } else {
        cdr << last_acknack_count;
        cdr << last_nackfrag_count;
        cdr << changes_low_mark;
        serializeLocatorEntry(cdr, reader_proxy_general_locator_entry);
        serializeLocatorEntry(cdr, reader_proxy_async_locator_entry);
    }
}

void ProxyInfo::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> type;
    cdr >> is_alive;
    cdr >> start_time;
    if (type == STATICTIC_ENTITY_WRITER) {
        cdr >> last_heartbeat_count;
        cdr >> last_notified;
        cdr >> available_changes_max;
        cdr >> max_sequence_number;
        deserializeLocatorEntry(cdr, writer_proxy_locators_entry);
    } else {
        cdr >> last_acknack_count;
        cdr >> last_nackfrag_count;
        cdr >> changes_low_mark;
        deserializeLocatorEntry(cdr, reader_proxy_general_locator_entry);
        deserializeLocatorEntry(cdr, reader_proxy_async_locator_entry);
    }
}

size_t WriterReaderInfo::getCdrSerializedSize(const WriterReaderInfo& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 1 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);                      // type
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);                      // matched
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(data.guid);  // guid
    current_alignment +=
        4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + data.topic_name.size() + 1;  // topic_name
    current_alignment +=
        4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + data.type_name.size() + 1;  // type_name

    return current_alignment - initial_alignment;
}

void WriterReaderInfo::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << type;
    cdr << matched;
    serializeGuid(cdr, guid);
    cdr << topic_name;
    cdr << type_name;
}

void WriterReaderInfo::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> type;
    cdr >> matched;
    deserializeGuid(cdr, guid);
    cdr >> topic_name;
    cdr >> type_name;
}

size_t StatisticSendInfo::getCdrSerializedSize(const StatisticSendInfo& data, size_t current_alignment) {
    (void)data;
    size_t initial_alignment = current_alignment;
    // send_payload_length_avg
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);
    // send_count
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);
    // send_throughput
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);
    // last_pkt_timestamp
    current_alignment += 8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 8U);
    // first_pkt_timestamp
    current_alignment += 8 + vbsutil::ecdr::Cdr::alignment(current_alignment, 8U);

    return current_alignment - initial_alignment;
}

void StatisticSendInfo::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << send_payload_length_avg;
    cdr << send_count;
    cdr << send_throughput;
    cdr << last_pkt_timestamp;
    cdr << first_pkt_timestamp;
}

void StatisticSendInfo::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> send_payload_length_avg;
    cdr >> send_count;
    cdr >> send_throughput;
    cdr >> last_pkt_timestamp;
    cdr >> first_pkt_timestamp;
}

size_t StatisticRecvInfo::getCdrSerializedSize(const StatisticRecvInfo& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    // recv_count size
    current_alignment += 4 + sizeof(uint32_t);

    // recv_count
    for (size_t i = 0; i < data.recv_count.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(ertps::rtps::GUID_t);
        current_alignment += sizeof(uint64_t);
    }

    // lost_count size
    current_alignment += 4 + sizeof(uint32_t);

    // lost_count
    for (size_t i = 0; i < data.lost_count.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(ertps::rtps::GUID_t);
        current_alignment += sizeof(uint64_t);
    }

    // avg_latancy size
    current_alignment += 4 + sizeof(size_t);

    // avg_latancy
    for (size_t i = 0; i < data.avg_latancy.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(ertps::rtps::GUID_t);
        current_alignment += sizeof(uint64_t);
    }

    // avg_throughput size
    current_alignment += 4 + sizeof(uint32_t);

    // avg_throughput
    for (size_t i = 0; i < data.avg_throughput.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(ertps::rtps::GUID_t);
        current_alignment += sizeof(uint64_t);
    }
    // take count total
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);
    // untake count
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    // last_pkt_timestamp size
    current_alignment += 4 + sizeof(uint32_t);
    // last_pkt_timestamp
    for (size_t i = 0; i < data.last_pkt_timestamp.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(ertps::rtps::GUID_t);
        current_alignment += sizeof(int64_t);
    }
    // first_pkt_timestamp
    for (size_t i = 0; i < data.first_pkt_timestamp.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(ertps::rtps::GUID_t);
        current_alignment += 4 + sizeof(int64_t);
    }
    // rejected_count
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    return current_alignment - initial_alignment;
}

void StatisticRecvInfo::serialize(vbsutil::ecdr::Cdr& cdr) const {
    uint32_t size = recv_count.size();
    cdr << size;
    for (auto& it : recv_count) {
        serializeGuid(cdr, it.first);
        cdr << it.second;
    }

    size = lost_count.size();
    cdr << size;
    for (auto& it : lost_count) {
        serializeGuid(cdr, it.first);
        cdr << it.second;
    }
    size = avg_latancy.size();
    cdr << size;
    for (auto& it : avg_latancy) {
        serializeGuid(cdr, it.first);
        cdr << it.second;
    }
    size = avg_throughput.size();
    cdr << size;
    for (auto& it : avg_throughput) {
        serializeGuid(cdr, it.first);
        cdr << it.second;
    }
    size = last_pkt_timestamp.size();
    cdr << size;
    for (auto& it : last_pkt_timestamp) {
        serializeGuid(cdr, it.first);
        cdr << it.second;
    }
    size = first_pkt_timestamp.size();
    cdr << size;
    for (auto& it : first_pkt_timestamp) {
        serializeGuid(cdr, it.first);
        cdr << it.second;
    }
    cdr << take_count_total;
    cdr << untake_count;
    cdr << rejected_count;
}

void StatisticRecvInfo::deserialize(vbsutil::ecdr::Cdr& cdr) {
    uint32_t size = 0;
    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ertps::rtps::GUID_t guid;
        uint64_t value;
        deserializeGuid(cdr, guid);
        cdr >> value;
        recv_count[guid] = value;
    }

    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ertps::rtps::GUID_t guid;
        uint64_t value;
        deserializeGuid(cdr, guid);
        cdr >> value;
        lost_count[guid] = value;
    }

    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ertps::rtps::GUID_t guid;
        uint64_t value;
        deserializeGuid(cdr, guid);
        cdr >> value;
        avg_latancy[guid] = value;
    }

    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ertps::rtps::GUID_t guid;
        uint64_t value;
        deserializeGuid(cdr, guid);
        cdr >> value;
        avg_throughput[guid] = value;
    }
    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ertps::rtps::GUID_t guid;
        int64_t value;
        deserializeGuid(cdr, guid);
        cdr >> value;
        last_pkt_timestamp[guid] = value;
    }
    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ertps::rtps::GUID_t guid;
        int64_t value;
        deserializeGuid(cdr, guid);
        cdr >> value;
        first_pkt_timestamp[guid] = value;
    }
    cdr >> take_count_total;
    cdr >> untake_count;
    cdr >> rejected_count;
}

size_t StatisticWriterReaderQos::getCdrSerializedSize(const StatisticWriterReaderQos& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;
    const uint32_t kinds_count = 6;
    const uint32_t int32_count = 6;
    const uint32_t duration_count = 6;
    current_alignment += 4 + sizeof(uint32_t) * kinds_count + sizeof(int32_t) * int32_count;
    current_alignment += 4 + sizeof(Duration_t) * duration_count;

    current_alignment += 4 + data.flowctlname.size() + 1;
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + 1;  // e2e_enable
    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + 1;  // send_multi_enable
    return current_alignment - initial_alignment;
}

void StatisticWriterReaderQos::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << durability;
    cdr << deadline.seconds;
    cdr << deadline.nanosec;
    cdr << liveliness_kind;
    cdr << liveliness_lease_duration.seconds;
    cdr << liveliness_lease_duration.nanosec;
    cdr << liveliness_announcement_period.seconds;
    cdr << liveliness_announcement_period.nanosec;
    cdr << reliability_kind;
    cdr << reliability_max_blocking_time.seconds;
    cdr << reliability_max_blocking_time.nanosec;
    cdr << history_kind;
    cdr << history_depth;
    cdr << max_samples;
    cdr << max_instances;
    cdr << max_samples_per_instance;
    cdr << allocated_samples;
    cdr << extra_samples;
    cdr << lifespan.seconds;
    cdr << lifespan.nanosec;
    cdr << ownership;
    cdr << pub_mode;
    cdr << flowctlname;
    cdr << e2e_enable;
    cdr << send_multi_enable;
}

void StatisticWriterReaderQos::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> durability;
    cdr >> deadline.seconds;
    cdr >> deadline.nanosec;
    cdr >> liveliness_kind;
    cdr >> liveliness_lease_duration.seconds;
    cdr >> liveliness_lease_duration.nanosec;
    cdr >> liveliness_announcement_period.seconds;
    cdr >> liveliness_announcement_period.nanosec;
    cdr >> reliability_kind;
    cdr >> reliability_max_blocking_time.seconds;
    cdr >> reliability_max_blocking_time.nanosec;
    cdr >> history_kind;
    cdr >> history_depth;
    cdr >> max_samples;
    cdr >> max_instances;
    cdr >> max_samples_per_instance;
    cdr >> allocated_samples;
    cdr >> extra_samples;
    cdr >> lifespan.seconds;
    cdr >> lifespan.nanosec;
    cdr >> ownership;
    cdr >> pub_mode;
    cdr >> flowctlname;
    cdr >> e2e_enable;
    cdr >> send_multi_enable;
}

size_t Lookup_getWriterReaderInfo_Result::getCdrSerializedSize(const Lookup_getWriterReaderInfo_Result& data,
                                                               size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    for (size_t i = 0; i < data.infos_.size(); ++i) {
        current_alignment += data.infos_[i].getCdrSerializedSize(data.infos_[i], current_alignment);
    }
    return current_alignment - initial_alignment;
}

void Lookup_getWriterReaderInfo_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << infos_;
}

void Lookup_getWriterReaderInfo_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> infos_;
}

size_t Lookup_getMatchGuids_Result::getCdrSerializedSize(const Lookup_getMatchGuids_Result& data,
                                                         size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    // vector size
    current_alignment += 4 + sizeof(uint32_t);

    // vector of guids
    for (size_t i = 0; i < data.guids_.size(); ++i) {
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U) + sizeof(data.guids_[i]);  // guid
    }
    return current_alignment - initial_alignment;
}

void Lookup_getMatchGuids_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    uint32_t size = guids_.size();
    cdr << size;

    for (size_t i = 0; i < guids_.size(); ++i) {
        serializeGuid(cdr, guids_[i]);
    }
}

void Lookup_getMatchGuids_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    uint32_t guids_size = 0;
    cdr >> guids_size;
    for (size_t i = 0; i < guids_size; ++i) {
        ertps::rtps::GUID_t guid;
        deserializeGuid(cdr, guid);
        guids_.push_back(guid);
    }
}

size_t Lookup_getSendInfo_Result::getCdrSerializedSize(const Lookup_getSendInfo_Result& data,
                                                       size_t current_alignment) {
    size_t initial_alignment = current_alignment;
    current_alignment += data.info_.getCdrSerializedSize(data.info_, current_alignment);
    return current_alignment - initial_alignment;
}

void Lookup_getSendInfo_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << info_;
}

void Lookup_getSendInfo_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> info_;
}

size_t Lookup_getRecvInfo_Result::getCdrSerializedSize(const Lookup_getRecvInfo_Result& data,
                                                       size_t current_alignment) {
    size_t initial_alignment = current_alignment;
    current_alignment += data.info_.getCdrSerializedSize(data.info_, current_alignment);
    return current_alignment - initial_alignment;
}

void Lookup_getRecvInfo_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << info_;
}

void Lookup_getRecvInfo_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> info_;
}

size_t Lookup_getWriterQos_Result::getCdrSerializedSize(const Lookup_getWriterQos_Result& data,
                                                        size_t current_alignment) {
    size_t initial_alignment = current_alignment;
    current_alignment += data.qos_.getCdrSerializedSize(data.qos_, current_alignment);
    return current_alignment - initial_alignment;
}

void Lookup_getWriterQos_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << qos_;
}

void Lookup_getWriterQos_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> qos_;
}

size_t Lookup_getTypeInfo_Result::getCdrSerializedSize(const Lookup_getTypeInfo_Result& data,
                                                       size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4) + data.type_name.size() + 1;
    current_alignment += ertps::types::TypeInformation::getCdrSerializedSize(data.information, current_alignment);
    return current_alignment - initial_alignment;
}

void Lookup_getTypeInfo_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    cdr << type_name;
    cdr << information;
}

void Lookup_getTypeInfo_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    cdr >> type_name;
    cdr >> information;
}

size_t Lookup_getTypes_Result::getCdrSerializedSize(const Lookup_getTypes_Result& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4U + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    for (size_t a = 0U; a < data.types.size(); ++a) {
        current_alignment += TypeIdentifierTypeObjectPair::getCdrSerializedSize(data.types.at(a), current_alignment);
    }

    current_alignment += 4U + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    for (size_t a = 0U; a < data.complete_to_minimal.size(); ++a) {
        current_alignment +=
            TypeIdentifierPair::getCdrSerializedSize(data.complete_to_minimal.at(a), current_alignment);
    }

    return current_alignment - initial_alignment;
}

void Lookup_getTypes_Result::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << types;
    scdr << complete_to_minimal;
}

void Lookup_getTypes_Result::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> types;
    dcdr >> complete_to_minimal;
}

size_t Lookup_getTypeDependencies_Req::getCdrSerializedSize(const Lookup_getTypeDependencies_Req& data,
                                                            size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4U + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    for (size_t a = 0U; a < data.type_ids.size(); ++a) {
        current_alignment += TypeIdentifier::getCdrSerializedSize(data.type_ids.at(a), current_alignment);
    }

    current_alignment += 4U + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    current_alignment += (data.continuation_point.size() * 1U) + vbsutil::ecdr::Cdr::alignment(current_alignment, 1U);

    return current_alignment - initial_alignment;
}

void Lookup_getTypeDependencies_Req::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << type_ids;
    scdr << continuation_point;
}

void Lookup_getTypeDependencies_Req::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> type_ids;
    dcdr >> continuation_point;
}

size_t Lookup_getTypeDependencies_Result::getCdrSerializedSize(const Lookup_getTypeDependencies_Result& data,
                                                               size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4U + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    for (size_t a = 0U; a < data.dependent_typeids.size(); ++a) {
        current_alignment +=
            TypeIdentifierWithSize::getCdrSerializedSize(data.dependent_typeids.at(a), current_alignment);
    }

    current_alignment += 4U + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);

    current_alignment += (data.continuation_point.size() * 1U) + vbsutil::ecdr::Cdr::alignment(current_alignment, 1U);

    return current_alignment - initial_alignment;
}

void Lookup_getTypeDependencies_Result::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << dependent_typeids;
    scdr << continuation_point;
}

void Lookup_getTypeDependencies_Result::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> dependent_typeids;
    dcdr >> continuation_point;
}

size_t Lookup_getMsgBrief_Result::getCdrSerializedSize(const Lookup_getMsgBrief_Result& data,
                                                       size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // map size
    for (auto& map_it : data.guid_msg_briefs_) {
        current_alignment += 4 + data.guid_msg_briefs_.size() * sizeof(map_it.first);   // guid
        current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);  // list size
        current_alignment += 4 + map_it.second.size() * sizeof(Log::MessageBrief);      // list size * message brief
    }

    return current_alignment - initial_alignment;
}

void Lookup_getMsgBrief_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    uint32_t map_size = guid_msg_briefs_.size();
    cdr << map_size;
    for (auto& map_it : guid_msg_briefs_) {
        serializeGuid(cdr, map_it.first);
        auto& msg_brief_list = map_it.second;
        cdr << msg_brief_list.size();
        for (const auto& list_it : msg_brief_list) {
            const Log::MessageBrief& msg_brief = list_it;
            cdr << msg_brief.is_writer;
            cdr << msg_brief.length;
            cdr << msg_brief.sequence;
            cdr << msg_brief.source_timestamp;
            cdr << msg_brief.dst_timestamp;
        }
    }
}

void Lookup_getMsgBrief_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    uint32_t map_size;
    cdr >> map_size;
    for (uint32_t i = 0; i < map_size; i++) {
        GUID_t guid;
        deserializeGuid(cdr, guid);
        size_t list_size;
        std::list<Log::MessageBrief> msg_brief_list;
        cdr >> list_size;
        for (size_t j = 0; j < list_size; j++) {
            Log::MessageBrief msg_brief;
            cdr >> msg_brief.is_writer;
            cdr >> msg_brief.length;
            cdr >> msg_brief.sequence;
            cdr >> msg_brief.source_timestamp;
            cdr >> msg_brief.dst_timestamp;
            msg_brief_list.emplace_back(msg_brief);
        }
        guid_msg_briefs_[guid] = std::move(msg_brief_list);
    }
}

size_t Lookup_getProxyInfos_Result::getCdrSerializedSize(const Lookup_getProxyInfos_Result& data,
                                                         size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    // vector size
    current_alignment += 4 + sizeof(uint32_t);

    // vector of guids
    for (size_t i = 0; i < data.proxy_infos_.size(); ++i) {
        current_alignment += ProxyInfo::getCdrSerializedSize(data.proxy_infos_[i], current_alignment) +
                             vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);
    }
    return current_alignment - initial_alignment;
}

void Lookup_getProxyInfos_Result::serialize(vbsutil::ecdr::Cdr& cdr) const {
    uint32_t size = proxy_infos_.size();
    cdr << size;

    for (size_t i = 0; i < proxy_infos_.size(); ++i) {
        proxy_infos_[i].serialize(cdr);
    }
}

void Lookup_getProxyInfos_Result::deserialize(vbsutil::ecdr::Cdr& cdr) {
    uint32_t size = 0;
    cdr >> size;
    for (size_t i = 0; i < size; ++i) {
        ProxyInfo info;
        info.deserialize(cdr);
        proxy_infos_.push_back(std::move(info));
    }
}

Lookup_Call::Lookup_Call() {
    m__d = Lookup_getTypes_Hash;
}

Lookup_Call::~Lookup_Call() {}

Lookup_Call::Lookup_Call(const Lookup_Call& x) {
    m__d = x.m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
        case Statistic_getMatchGuids_Hash:
        case Statistic_getSendInfo_Hash:
        case Statistic_getRecvInfo_Hash:
        case Statistic_getWriterReaderQos_Hash:
        case Statistic_getProxyInfo_Hash:
            m_getGuidInfo = x.m_getGuidInfo;
            break;
        case Lookup_getTypeInfo_Hash:
            m_getTypeName = x.m_getTypeName;
            break;
        case Lookup_getTypes_Hash:
            m_getTypes = x.m_getTypes;
            break;
        case Lookup_getDependencies_Hash:
            m_getTypeDependencies = x.m_getTypeDependencies;
            break;
        case Statistic_getMsgBrief_Hash:
        case Statistic_remoteConfig_Hash:
        case Statistic_getDServerInfo_Hash:
            m_remoteConfig = x.m_remoteConfig;
            break;
        default:
            break;
    }
}

Lookup_Call& Lookup_Call::operator=(const Lookup_Call& x) {
    m__d = x.m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
        case Statistic_getMatchGuids_Hash:
        case Statistic_getSendInfo_Hash:
        case Statistic_getRecvInfo_Hash:
        case Statistic_getWriterReaderQos_Hash:
        case Statistic_getProxyInfo_Hash:
            m_getGuidInfo = x.m_getGuidInfo;
            break;
        case Lookup_getTypeInfo_Hash:
            m_getTypeName = x.m_getTypeName;
            break;
        case Lookup_getTypes_Hash:
            m_getTypes = x.m_getTypes;
            break;
        case Lookup_getDependencies_Hash:
            m_getTypeDependencies = x.m_getTypeDependencies;
            break;
        case Statistic_getMsgBrief_Hash:
        case Statistic_remoteConfig_Hash:
        case Statistic_getDServerInfo_Hash:
            m_remoteConfig = x.m_remoteConfig;
            break;
        default:
            break;
    }

    return *this;
}

int32_t& Lookup_Call::_d() {
    return m__d;
}

void Lookup_Call::getGuidInfo(const Statistic_getInfoByGuid_Req& _getGuidInfo, int32_t hash_id) {
    m_getGuidInfo = _getGuidInfo;
    m__d = hash_id;
}

const Statistic_getInfoByGuid_Req& Lookup_Call::getGuidInfo() const {
    bool b = false;
    switch (m__d) {
        case Statistic_getWRInfo_Hash:
        case Statistic_getMatchGuids_Hash:
        case Statistic_getSendInfo_Hash:
        case Statistic_getRecvInfo_Hash:
        case Statistic_getWriterReaderQos_Hash:
        case Statistic_getProxyInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }
    return m_getGuidInfo;
}

void Lookup_Call::remoteConfig(const Lookup_remoteConfig_Req& _remoteConfigReq, int32_t kind) {
    m_remoteConfig = _remoteConfigReq;
    m__d = kind;
}

const Lookup_remoteConfig_Req& Lookup_Call::remoteConfig() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getMsgBrief_Hash:
        case Statistic_remoteConfig_Hash:
        case Statistic_getDServerInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_remoteConfig;
}

void Lookup_Call::getTypeInfo(const Lookup_getTypeInfo_Req& _getTypeInfo) {
    m_getTypeName = _getTypeInfo;
    m__d = Lookup_getTypeInfo_Hash;
}

const Lookup_getTypeInfo_Req& Lookup_Call::getTypeInfo() const {
    bool b = false;

    switch (m__d) {
        case Lookup_getTypeInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getTypeName;
}

void Lookup_Call::getTypes(const Lookup_getTypes_Req& _getTypes) {
    m_getTypes = _getTypes;
    m__d = Lookup_getTypes_Hash;
}

const Lookup_getTypes_Req& Lookup_Call::getTypes() const {
    bool b = false;

    switch (m__d) {
        case Lookup_getTypes_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getTypes;
}

void Lookup_Call::getTypeDependencies(const Lookup_getTypeDependencies_Req& _getTypeDependencies) {
    m_getTypeDependencies = _getTypeDependencies;
    m__d = Lookup_getDependencies_Hash;
}

const Lookup_getTypeDependencies_Req& Lookup_Call::getTypeDependencies() const {
    bool b = false;

    switch (m__d) {
        case Lookup_getDependencies_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getTypeDependencies;
}

size_t Lookup_Call::getCdrSerializedSize(const Lookup_Call& data, size_t current_alignment) {
    (void)data;
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4);

    switch (data.m__d) {
        case Statistic_getWRInfo_Hash:
        case Statistic_getMatchGuids_Hash:
        case Statistic_getSendInfo_Hash:
        case Statistic_getRecvInfo_Hash:
        case Statistic_getWriterReaderQos_Hash:
        case Statistic_getProxyInfo_Hash:
            current_alignment +=
                Statistic_getInfoByGuid_Req::getCdrSerializedSize(data.getGuidInfo(), current_alignment);
            break;
        case Statistic_getMsgBrief_Hash:
        case Statistic_remoteConfig_Hash:
        case Statistic_getDServerInfo_Hash:
            current_alignment += Lookup_remoteConfig_Req::getCdrSerializedSize(data.remoteConfig(), current_alignment);
            break;
        case Lookup_getTypeInfo_Hash:
            current_alignment += Lookup_getTypeInfo_Req::getCdrSerializedSize(data.getTypeInfo(), current_alignment);
            break;
        case Lookup_getTypes_Hash:
            current_alignment += Lookup_getTypes_Req::getCdrSerializedSize(data.getTypes(), current_alignment);
            break;
        case Lookup_getDependencies_Hash:
            current_alignment +=
                Lookup_getTypeDependencies_Req::getCdrSerializedSize(data.getTypeDependencies(), current_alignment);
            break;
        default:
            break;
    }

    return current_alignment - initial_alignment;
}

void Lookup_Call::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
        case Statistic_getMatchGuids_Hash:
        case Statistic_getSendInfo_Hash:
        case Statistic_getRecvInfo_Hash:
        case Statistic_getWriterReaderQos_Hash:
        case Statistic_getProxyInfo_Hash:
            scdr << m_getGuidInfo;
            break;
        case Lookup_getTypeInfo_Hash:
            scdr << m_getTypeName;
            break;
        case Lookup_getTypes_Hash:
            scdr << m_getTypes;
            break;
        case Lookup_getDependencies_Hash:
            scdr << m_getTypeDependencies;
            break;
        case Statistic_getMsgBrief_Hash:
        case Statistic_remoteConfig_Hash:
        case Statistic_getDServerInfo_Hash:
            scdr << m_remoteConfig;
            break;
        default:
            break;
    }
}

void Lookup_Call::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
        case Statistic_getMatchGuids_Hash:
        case Statistic_getSendInfo_Hash:
        case Statistic_getRecvInfo_Hash:
        case Statistic_getWriterReaderQos_Hash:
        case Statistic_getProxyInfo_Hash:
            dcdr >> m_getGuidInfo;
            break;
        case Lookup_getTypeInfo_Hash:
            dcdr >> m_getTypeName;
            break;
        case Lookup_getTypes_Hash:
            dcdr >> m_getTypes;
            break;
        case Lookup_getDependencies_Hash:
            dcdr >> m_getTypeDependencies;
            break;
        case Statistic_getMsgBrief_Hash:
        case Statistic_remoteConfig_Hash:
        case Statistic_getDServerInfo_Hash:
            dcdr >> m_remoteConfig;
            break;
        default:
            break;
    }
}

Lookup_Return::Lookup_Return() {
    m__d = Lookup_getTypes_Hash;
}

Lookup_Return::~Lookup_Return() {}

Lookup_Return::Lookup_Return(const Lookup_Return& x) {
    m__d = x.m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
            m_getWRInfo = x.m_getWRInfo;
            break;
        case Statistic_getMatchGuids_Hash:
            m_getMatchGuids = x.m_getMatchGuids;
            break;
        case Statistic_getSendInfo_Hash:
            m_getSendInfo = x.m_getSendInfo;
            break;
        case Statistic_getRecvInfo_Hash:
            m_getRecvInfo = x.m_getRecvInfo;
            break;
        case Lookup_getTypeInfo_Hash:
            m_getTypeInfo = x.m_getTypeInfo;
            break;
        case Lookup_getTypes_Hash:
            m_getType = x.m_getType;
            break;
        case Lookup_getDependencies_Hash:
            m_getTypeDependencies = x.m_getTypeDependencies;
            break;
        case Statistic_getProxyInfo_Hash:
            m_getProxyInfos = x.m_getProxyInfos;
            break;
        case Statistic_remoteConfig_Hash:
            m_remoteConfig = x.m_remoteConfig;
            break;
        case Statistic_getDServerInfo_Hash:
            m_dserverInfo = x.m_dserverInfo;
            break;
        default:
            break;
    }
}

Lookup_Return& Lookup_Return::operator=(const Lookup_Return& x) {
    m__d = x.m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
            m_getWRInfo = x.m_getWRInfo;
            break;
        case Statistic_getMatchGuids_Hash:
            m_getMatchGuids = x.m_getMatchGuids;
            break;
        case Statistic_getSendInfo_Hash:
            m_getSendInfo = x.m_getSendInfo;
            break;
        case Statistic_getRecvInfo_Hash:
            m_getRecvInfo = x.m_getRecvInfo;
            break;
        case Lookup_getTypeInfo_Hash:
            m_getTypeInfo = x.m_getTypeInfo;
            break;
        case Lookup_getTypes_Hash:
            m_getType = x.m_getType;
            break;
        case Lookup_getDependencies_Hash:
            m_getTypeDependencies = x.m_getTypeDependencies;
            break;
        case Statistic_getProxyInfo_Hash:
            m_getProxyInfos = x.m_getProxyInfos;
            break;
        case Statistic_remoteConfig_Hash:
            m_remoteConfig = x.m_remoteConfig;
            break;
        case Statistic_getDServerInfo_Hash:
            m_dserverInfo = x.m_dserverInfo;
            break;
        default:
            break;
    }

    return *this;
}

int32_t& Lookup_Return::_d() {
    return m__d;
}

void Lookup_Return::getMsgBreifInfo(const Lookup_getMsgBrief_Result& _getMsgBriefInfo) {
    m_getMsgBriefInfo = _getMsgBriefInfo;
    m__d = Statistic_getMsgBrief_Hash;
}

const Lookup_getMsgBrief_Result& Lookup_Return::getMsgBreifInfo() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getMsgBrief_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getMsgBriefInfo;
}

void Lookup_Return::getWriterReaderInfo(const Lookup_getWriterReaderInfo_Result& _getWRInfo) {
    m_getWRInfo = _getWRInfo;
    m__d = Statistic_getWRInfo_Hash;
}

const Lookup_getWriterReaderInfo_Result& Lookup_Return::getWriterReaderInfo() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getWRInfo;
}

void Lookup_Return::getMatchGuids(const Lookup_getMatchGuids_Result& _getMatchGuids) {
    m_getMatchGuids = _getMatchGuids;
    m__d = Statistic_getMatchGuids_Hash;
}

const Lookup_getMatchGuids_Result& Lookup_Return::getMatchGuids() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getMatchGuids_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getMatchGuids;
}

void Lookup_Return::getProxyInfos(const Lookup_getProxyInfos_Result& _getProxyInfos) {
    m_getProxyInfos = _getProxyInfos;
    m__d = Statistic_getProxyInfo_Hash;
}

const Lookup_getProxyInfos_Result& Lookup_Return::getProxyInfos() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getProxyInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getProxyInfos;
}

void Lookup_Return::getSendInfo(const Lookup_getSendInfo_Result& _getSendInfo) {
    m_getSendInfo = _getSendInfo;
    m__d = Statistic_getSendInfo_Hash;
}

const Lookup_getSendInfo_Result& Lookup_Return::getSendInfo() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getSendInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getSendInfo;
}

void Lookup_Return::getRecvInfo(const Lookup_getRecvInfo_Result& _getRecvInfo) {
    m_getRecvInfo = _getRecvInfo;
    m__d = Statistic_getRecvInfo_Hash;
}

const Lookup_getRecvInfo_Result& Lookup_Return::getRecvInfo() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getRecvInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getRecvInfo;
}

void Lookup_Return::getWriterQos(const Lookup_getWriterQos_Result& _getWriterQos) {
    m_getWriterQos = _getWriterQos;
    m__d = Statistic_getWriterReaderQos_Hash;
}

const Lookup_getWriterQos_Result& Lookup_Return::getWriterQos() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getWriterReaderQos_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getWriterQos;
}

void Lookup_Return::getTypeInfo(const Lookup_getTypeInfo_Result& _getTypeInfo) {
    m_getTypeInfo = _getTypeInfo;
    m__d = Lookup_getTypeInfo_Hash;
}

const Lookup_getTypeInfo_Result& Lookup_Return::getTypeInfo() const {
    bool b = false;

    switch (m__d) {
        case Lookup_getTypeInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getTypeInfo;
}

void Lookup_Return::getType(const Lookup_getTypes_Result& _getType) {
    m_getType = _getType;
    m__d = Lookup_getTypes_Hash;
}

const Lookup_getTypes_Result& Lookup_Return::getType() const {
    bool b = false;

    switch (m__d) {
        case Lookup_getTypes_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getType;
}

void Lookup_Return::getTypeDependencies(const Lookup_getTypeDependencies_Result& _getTypeDependencies) {
    m_getTypeDependencies = _getTypeDependencies;
    m__d = Lookup_getDependencies_Hash;
}

const Lookup_getTypeDependencies_Result& Lookup_Return::getTypeDependencies() const {
    bool b = false;

    switch (m__d) {
        case Lookup_getDependencies_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_getTypeDependencies;
}

void Lookup_Return::remoteConfig(const Lookup_remoteConfig_Result& _remoteConfig) {
    m_remoteConfig = _remoteConfig;
    m__d = Statistic_remoteConfig_Hash;
}

const Lookup_remoteConfig_Result& Lookup_Return::remoteConfig() const {
    bool b = false;

    switch (m__d) {
        case Statistic_remoteConfig_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_remoteConfig;
}

void Lookup_Return::dserverInfo(const Lookup_getDServerInfo_Result& _info) {
    m_dserverInfo = _info;
    m__d = Statistic_getDServerInfo_Hash;
}

const Lookup_getDServerInfo_Result& Lookup_Return::dserverInfo() const {
    bool b = false;

    switch (m__d) {
        case Statistic_getDServerInfo_Hash:
            b = true;
            break;
        default:
            break;
    }
    if (!b) {
        throw BadParamException("This member is not been selected");
    }

    return m_dserverInfo;
}

size_t Lookup_Return::getCdrSerializedSize(const Lookup_Return& data, size_t current_alignment) {
    size_t initial_alignment = current_alignment;

    current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4);

    switch (data.m__d) {
        case Statistic_getWRInfo_Hash:
            current_alignment +=
                Lookup_getWriterReaderInfo_Result::getCdrSerializedSize(data.getWriterReaderInfo(), current_alignment);
            break;
        case Statistic_getMatchGuids_Hash:
            current_alignment +=
                Lookup_getMatchGuids_Result::getCdrSerializedSize(data.getMatchGuids(), current_alignment);
            break;
        case Statistic_getSendInfo_Hash:
            current_alignment += Lookup_getSendInfo_Result::getCdrSerializedSize(data.getSendInfo(), current_alignment);
            break;
        case Statistic_getRecvInfo_Hash:
            current_alignment += Lookup_getRecvInfo_Result::getCdrSerializedSize(data.getRecvInfo(), current_alignment);
            break;
        case Statistic_getWriterReaderQos_Hash:
            current_alignment +=
                Lookup_getWriterQos_Result::getCdrSerializedSize(data.getWriterQos(), current_alignment);
            break;
        case Lookup_getTypeInfo_Hash:
            current_alignment += Lookup_getTypeInfo_Result::getCdrSerializedSize(data.getTypeInfo(), current_alignment);
            break;
        case Lookup_getTypes_Hash:
            current_alignment += Lookup_getTypes_Result::getCdrSerializedSize(data.getType(), current_alignment);
            break;
        case Lookup_getDependencies_Hash:
            current_alignment +=
                Lookup_getTypeDependencies_Result::getCdrSerializedSize(data.getTypeDependencies(), current_alignment);
            break;
        case Statistic_getMsgBrief_Hash:
            current_alignment +=
                Lookup_getMsgBrief_Result::getCdrSerializedSize(data.getMsgBreifInfo(), current_alignment);
            break;
        case Statistic_getProxyInfo_Hash:
            current_alignment +=
                Lookup_getProxyInfos_Result::getCdrSerializedSize(data.getProxyInfos(), current_alignment);
            break;
        case Statistic_remoteConfig_Hash:
            current_alignment += 4 + vbsutil::ecdr::Cdr::alignment(current_alignment, 4U);
            break;
        case Statistic_getDServerInfo_Hash:
            current_alignment +=
                Lookup_getDServerInfo_Result::getCdrSerializedSize(data.dserverInfo(), current_alignment);
            break;
        default:
            break;
    }

    return current_alignment - initial_alignment;
}

void Lookup_Return::serialize(vbsutil::ecdr::Cdr& scdr) const {
    scdr << m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
            scdr << m_getWRInfo;
            break;
        case Statistic_getMatchGuids_Hash:
            scdr << m_getMatchGuids;
            break;
        case Statistic_getSendInfo_Hash:
            scdr << m_getSendInfo;
            break;
        case Statistic_getRecvInfo_Hash:
            scdr << m_getRecvInfo;
            break;
        case Statistic_getWriterReaderQos_Hash:
            scdr << m_getWriterQos;
            break;
        case Lookup_getTypeInfo_Hash:
            scdr << m_getTypeInfo;
            break;
        case Lookup_getTypes_Hash:
            scdr << m_getType;
            break;
        case Lookup_getDependencies_Hash:
            scdr << m_getTypeDependencies;
            break;
        case Statistic_getMsgBrief_Hash:
            scdr << m_getMsgBriefInfo;
            break;
        case Statistic_getProxyInfo_Hash:
            scdr << m_getProxyInfos;
            break;
        case Statistic_remoteConfig_Hash:
            scdr << m_remoteConfig.result_;
            break;
        case Statistic_getDServerInfo_Hash:
            scdr << m_dserverInfo.infos_;
            break;
        default:
            break;
    }
}

void Lookup_Return::deserialize(vbsutil::ecdr::Cdr& dcdr) {
    dcdr >> m__d;

    switch (m__d) {
        case Statistic_getWRInfo_Hash:
            dcdr >> m_getWRInfo;
            break;
        case Statistic_getMatchGuids_Hash:
            dcdr >> m_getMatchGuids;
            break;
        case Statistic_getSendInfo_Hash:
            dcdr >> m_getSendInfo;
            break;
        case Statistic_getRecvInfo_Hash:
            dcdr >> m_getRecvInfo;
            break;
        case Statistic_getWriterReaderQos_Hash:
            dcdr >> m_getWriterQos;
            break;
        case Lookup_getTypeInfo_Hash:
            dcdr >> m_getTypeInfo;
            break;
        case Lookup_getTypes_Hash:
            dcdr >> m_getType;
            break;
        case Lookup_getDependencies_Hash:
            dcdr >> m_getTypeDependencies;
            break;
        case Statistic_getMsgBrief_Hash:
            dcdr >> m_getMsgBriefInfo;
            break;
        case Statistic_getProxyInfo_Hash:
            dcdr >> m_getProxyInfos;
            break;
        case Statistic_remoteConfig_Hash:
            dcdr >> m_remoteConfig.result_;
            break;
        case Statistic_getDServerInfo_Hash:
            dcdr >> m_dserverInfo.infos_;
        default:
            break;
    }
}
